package javaMetaModel;

import javaMetaModel.type.MetaType;
import javaMetaModel.visitor.IMetaModelVisitor;

public class Attribute extends Declaration implements IVisibleEntity {

	protected Object mDefaultValue;

	protected final Visibility mVisibility = new Visibility();

	protected String mCardinality;

	public Attribute(MetaType aType, String aName) {
		this(aType, aName, "1");
	}

	public Attribute(MetaType aType, String aName, String aCardinality) {
		super(aType, aName);
		this.mCardinality = aCardinality;
	}

	public void accept(IMetaModelVisitor aVisitor) {
		aVisitor.visitAttribute(this);
	}

	@Override
	public void setPrivate() {
		this.mVisibility.setPrivate();
	}

	@Override
	public void setProtected() {
		this.mVisibility.setProtected();
	}

	@Override
	public void setPublic() {
		this.mVisibility.setPublic();
	}

	@Override
	public Visibility getVisibility() {
		return mVisibility;
	}

	@Override
	public boolean isPrivate() {
		return this.mVisibility.isPrivate();
	}

	@Override
	public boolean isProtected() {
		return this.mVisibility.isProtected();
	}

	@Override
	public boolean isPublic() {
		return this.mVisibility.isPublic();
	}

	public Object getDefaultValue() {
		return mDefaultValue;
	}

	public void setDefaultValue(Object mDefaultValue) {
		this.mDefaultValue = mDefaultValue;
	}

	public boolean isMultiple() {
		return !this.mCardinality.equals("1");
	}
}
